import { defHttp as request } from '/@/utils/http/axios'

export const getDictList = (p) => {
    return request.post({
        url: '/core/dict/getDictList',
        data: p
    });
};
interface IDict {
  dictCode: string;
  dictName: string;
  remark: string;
  id?: number;
}
export const createDictType = (p: IDict) => {
    return request.post({
        url: '/core/dict/addDict',
        data: p
    });
};

export const deleteDictType = (p: Array<string>) => {
    return request.post({
        url: '/core/dict/batchDeleteDict',
        data: {
          dictIds: p
        }
    });
};

export const updateDictType = (p: IDict) => {
    return request.post({
        url: '/core/dict/updateDict',
        data: p
    });
};

// 获取字典项
interface IGetDictData {
    pageSize?: number;
    startIndex?: number;
    dictCode: string;
}
export const getDictData = (p: IGetDictData) => {
    return request.post({
        url: '/core/dictItem/getDictItemsList',
        data: p
    });
};

interface IDictDataItem {
    name: string;
    value: string|number;
    sort?: number;
    dictId?: string;
    remark?: string;
    id?: string;
}

export const createDictDataItem = (p: IDictDataItem) => {
    return request.post({
        url: '/core/dictItem/addDictItem',
        data: p
    });
};
export const updateDictDataItem = (p: IDictDataItem) => {
    return request.post({
        url: '/core/dictItem/updateDictItem',
        data: p
    });
};
export const delDictDataItem = (p: Array<number>) => {
    return request.post({
        url: '/core/dictItem/batchDeleteDictItems',
        data: {
            ids: p
        }
    });
};